<?php
class ControllerUserUserLog extends AdminController {
	
	public function index() {
		M('user/user_log', 'mod_user');
		$this->getList();		
	}
	
	public function clear() {
		M('user/user_log', 'mod_user');
		if ($this->hasMP()) {
			if ($this->mod_user->clearUserLogs()) {
				$this->session->set_flashdata('success', $this->_['text_success']);
				$this->redirect(UA('user/user_log'));
			}
		}
		else {
			$this->setMessage('error_warning', $this->_['error_permission']);
		}
		$this->getList();
	}
	
	protected function getList() {
		$qf = new Query_filter();
		
		$total = $this->mod_user->getTotalUserLogs($qf);
		$this->data['logs'] = $this->mod_user->getUserLogs($qf);
		
		$this->data['pagination'] = $this->pagination($total)->render();
		
		$this->data['filter_username'] = $qf->get('filter_username');
		$this->data['filter_ip'] = $qf->get('filter_ip');
		$this->data['filter_date_added'] = $qf->get('filter_date_added');
		
		$this->display('user/user_log_list.tpl');
	}
}